__author__ = 'byrne_000'
from config import config


class NewStyleLogMessage(object):
    def __init__(self, message, *args, **kwargs):
        self.message = message
        self.args = args
        self.kwargs = kwargs

    def __str__(self):
        _args = (i() if callable(i) else i for i in self.args)
        kwargs = dict((k, v() if callable(v) else v) for k, v in self.kwargs.items())

        return self.message.format(*_args, **kwargs)


N = NewStyleLogMessage


def tag(obj, name):
    obj.add_tag('Name', name)
    obj.add_tag('Scope', config.SCOPE)
    obj.add_tag('Domain', config.DOMAIN)


def print_sg(sg):
    print('SecurityGroup:\n\tName:%s\n\tDescription:"%s\n\tID:%s\n\tRules:%s\n\tTags:%s' % (sg.name, sg.description, sg.id, sg.rules, sg.tags))

